/**
 * Copyright &copy; 2013-2015 山东易科德软件有限公司   All rights reserved.
 */
package cn.net.ecode.modules.file.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.net.ecode.common.config.Global;
import cn.net.ecode.common.web.BaseController;

import com.baidu.ueditor.ActionEnter;

/**
 * UEditor Controller
 * @author ThinkGem
 * @version 2015-7-2
 */
@Controller
@RequestMapping(value = "${adminPath}/file/ueditor")
public class UeditorController extends BaseController {

	@RequiresPermissions("user")
	@ResponseBody
	@RequestMapping(value = "")
	public String upload(HttpServletRequest request, HttpServletResponse response) {
		return upload(null, request, response);
	}

	@RequiresPermissions("user")
	@ResponseBody
	@RequestMapping(value = "{action}")
	public String upload(@PathVariable String action, HttpServletRequest request, HttpServletResponse response) {
		String rootPath = Global.getUserfilesBaseDir();
		return new ActionEnter(request, rootPath, action).exec();
	}

}